/*
 * Copyright 2009 Colin Prinn
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package net.recursv.motific.unittest.assertion;

/**
 * Created by: recursv
 * Date: 2/08/2009
 * Time: 8:15:18 PM
 */
public class EqualityAssertionException extends RuntimeException {
    private Object _expected;
    private Object _actual;
    private String _msg;

    public EqualityAssertionException(Object expected, Object actual) {
        _expected = expected;
        _actual = actual;
    }

    public EqualityAssertionException(int expected, int actual) {
        _expected = new Integer(expected);
        _actual = new Integer(actual);
    }

    public EqualityAssertionException(long expected, long actual) {
        _expected = new Long(expected);
        _actual = new Long(actual);
    }

    public EqualityAssertionException(String msg, Object expected, Object actual) {
        _msg = msg;
        _expected = expected;
        _actual = actual;
    }

    public EqualityAssertionException(String msg, int expected, int actual) {
        _msg = msg;
        _expected = new Integer(expected);
        _actual = new Integer(actual);
    }

    public EqualityAssertionException(String msg, long expected, long actual) {
        _msg = msg;
        _expected = new Long(expected);
        _actual = new Long(actual);
    }

    public String getMessage() {
        if (_msg == null)
            return "AssertEquals failed -> expected: " + (_expected == null ? "null" : _expected.toString()) + " , actual: " + (_actual == null ? "null" : _actual.toString());
        else
            return "AssertEquals failed [ " + _msg + " ] -> expected: " + (_expected == null ? "null" : _expected.toString()) + " , actual: " + (_actual == null ? "null" : _actual.toString());
    }

    public String toString() {
        return getMessage();
    }
}
